{% extends "base.html" %}

{% block content %}


    <h2>Make an Offer</h2>
    {% for msg in error_msgs %}
        <p class="errorMsg">{{msg}}</p>
    {% endfor %}
        <p>What would you like to sell?</p>
        <form method="post" action="/market/offer">
            <p><input type="text" name="sets" size="2"
              {% if sets %}
                value="{{sets}}"
              {% endif %}
              /> sets of 10 units of
              <select name="offer">
              {% for good in goods %}
                <option value="{{good}}"
                {% if offer %}
                {% ifequal offer good %}
                    selected="selected"
                {% endifequal %}
                {% endif %}
                >{{good|capfirst}}</option>
              {% endfor %}
              </select>
              for<br />
              <input type="text" name="units" size="2"
              {% if units %}
                value="{{units}}"
              {% endif %}
              /> units
              of
              <select name="request">
              {% for good in goods %}
                <option value="{{good}}"
                {% if request %}
                {% ifequal request good %}
                    selected="selected"
                {% endifequal %}
                {% endif %}
                >{{good|capfirst}}</option>
              {% endfor %}
              </select>
                per set
            </p>
            <p><input type="submit" value="Make Offer" /></p>
        </form>
    <hr />
    <h2>Your Offers</h2>
    <table>
        <tr>
            <th>Quantity</th>
            <th>Price</th>
            <th>Seller</th>
            <th></th>
        </tr>
        {% for offer in account.get_offers %}
            {% include "offer_row.html" %}
        {% endfor %}
    </table>
    <hr />
    <h2>Marketplace</h2>
    <form action="/market/view">
        <p>Looking for
            <select name="o_s">
            <option value="any">Any</option>
          {% for good in goods %}
            <option value="{{good}}"
                {% if offer_sort %}
                {% ifequal offer_sort good.name %}
                    selected="selected"
                {% endifequal %}
                {% endif %}
            >{{good|capfirst}}</option>
          {% endfor %}
            </select>
            in return for
            <select name="r_s">
            <option value="any">Any</option>
          {% for good in goods %}
            <option value="{{good}}"
                {% if request_sort %}
                {% ifequal request_sort good.name %}
                    selected="selected"
                {% endifequal %}
                {% endif %}
            >{{good|capfirst}}</option>
          {% endfor %}
            </select>
            <input type="submit" value="Sort" />
        </p>
    </form>
    <table>
        <tr>
            <th>Quantity</th>
            <th>Price</th>
            <th>Seller</th>
            <th></th>
        </tr>
        {% for offer in all_offers %}
            {% include "offer_row.html" %}
        {% endfor %}
    </table>
{% endblock %}